<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1,minimum-scale=1, user-scalable=no" />
    <title>touch事件属性追踪</title>
    <link rel="stylesheet" href="./css/common.css">
    <script src="./js/rem.js"></script>
    <style>
        .box {
            width: 2rem;
            height: 2rem;
            background-color: navajowhite;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="box"></div>
        <div class="content"></div>
    </div>
    <script>
        let el = document.querySelector('.box')
        let content = document.querySelector('.content')

        function appendElement(touch) {
            let html = `
            <div>id:${touch.identifier}</div>
            <div>clientX:${touch.clientX}</div>
            <div>clientY:${touch.clientY}</div>
            <div>pageX:${touch.pageX}</div>
            <div>pageY:${touch.pageY}</div>
            <div>screenX:${touch.screenX}<div>
            <div>screenY:${touch.screenY}<div>
            `
            content.innerHTML = html
        }

        el.addEventListener('touchstart', function (e) {
            let touch = e.changedTouches[0]
            appendElement(touch)
        }, false)

        el.addEventListener('touchmove', function (e) {
            let touch = e.changedTouches[0]
            appendElement(touch)
        }, false)
        
        el.addEventListener('touchend', function (e) {
            let touch = e.changedTouches[0]
            appendElement(touch)
        }, false)
    </script>
</body>

</html>